/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Duc Quyen
 */
public class Employer {
    private String companyName;
    private String address;
    private String description;
    private String phone;
    private String companySize;
    private String email;
   private int empID;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Employer() {
    }


    public Employer(String companyName, String address, String description, String phone, String companySize) {
        this.companyName = companyName;
        this.address = address;
        this.description = description;
        this.phone = phone;
        this.companySize = companySize;
    }

    public Employer(int id, String email, String companyName) {
        this.empID = id;
        this.email = email;
        this.companyName = companyName;
    }

    public Employer getEmployer(int id){
        Employer emp = null ;
        try {
            Connection con = ConnectDatabase.getConnection();
            String sql = "select * from employer where EmployerID=?";
            PreparedStatement sta = con.prepareStatement(sql);
            sta.setInt(1, id);
            ResultSet res = sta.executeQuery();
            res.next();
            companyName = res.getString(7);
            address = res.getString(4);
            description = res.getString(9);
            phone = res.getString(5);
            companySize = res.getString(8);
            emp = new Employer(companyName, address, description, phone, companySize);
            con.close();
        } catch (SQLException ex) {
           ex.printStackTrace();
        }

        return emp;
    }

    public String getAddress() {
        return address;
    }

    public String getCompanyName() {
        return companyName;
    }

    public String getCompanySize() {
        return companySize;
    }

    public String getDescription() {
        return description;
    }

    public int getEmpID() {
        return empID;
    }

    public String getPhone() {
        return phone;
    }
}
